<template>
<div class="content">
  <div class="progress">
    <img src="~assets/img/icon_jd_3@2x.png" alt="">
  </div>
  <div class="pay-status tc">
    <img src="~assets/img/icon-cg@2x.png" alt="支付成功">
    <p class="pay-status-title">支付成功</p>
    <p class="sub-descr">你的订单将尽快处理</p>
    <div class="pay-btns tc">
      <button style="opacity:1" class="common-btn ing-btn">审核中</button>
      <button style="opacity:1" class="common-btn" @click="refre()">刷新</button>
    </div>
  </div>
</div>
</template>

<script>
import { Indicator, MessageBox } from 'mint-ui'
export default {
  data () {
    return {
      timer: ''
    }
  },
  mounted () {
    var num = 3
    // this.timer = setInterval(() => {
    //   num--
    //   this.$refs.back.innerHTML = `${num}秒后返回个人中心`
    //   if (num === 0) {
    //     this.$router.push('/user')
    //   }
    // }, 1000)
    this.$apiPost('userstatus',{}).then((data) => {
      if (data.status === 0) {
         if (data.data.recode === 1005) {
            this.$router.push('/user')
          }
      } else {
        // MessageBox({title: '提示',message: data.msg})
        console.log(data.msg)
      }
    })
  },
  destroyed () {
    clearInterval(this.timer)
  },
  methods: {
    refre () {
      Indicator.open({
        text: 'Loading...',
        spinnerType: 'fading-circle'
      })
     this.$apiPost(`wait_refresh`,{})
        .then(data => {
          if (data.status === 0) {
            if (data.data.recode === 0) {
              setTimeout(() => {
                MessageBox({
                  title: '提示',
                  message: '正在审核中，请耐心等待。。'
                })
                Indicator.close()
              }, 1000)
            } else if (data.data.recode === 1) {
              setTimeout(() => {
                MessageBox({
                  title: '审核成功',
                  message:
                    '您已成功成为艾鑫电子商务一员，赶快快去体验电子商务的功能吧！'
                }).then(() => {
                this.$apiPost('vipsure',{}).then((data) => {
                })
              })
                Indicator.close()
                this.$router.push('/user')
              }, 1000)
            } else if (data.data.code === 2) {
              setTimeout(() => {
                MessageBox({
                  title: '提示',
                  message: '审核失败，请核对您的信息'
                })
                Indicator.close()
              }, 1000)
            }
          } else { MessageBox({title: '提示',message: data.msg })
          }
        })
        Indicator.close()
    },
    backs () {
      this.$router.push('/user')
    }
  }
}
</script>
<style scoped lang="scss">
.pay-status {
  img {
    width: 128px;
    height: 128px;
    margin: 15px 10px;
  }
  .pay-status-title {
    font-size: 36px;
  }
  .sub-descr {
    color: #999;
  }
  .ing-btn {
    background-color: #fff;
    color: #333;
  }
}
</style>
